<?php
include_once("dbconnect/db.php");
Class Category
{	
	var $topicPath;
	var $html;
	
	function getBigCatList()
	{
		$html = "";
		$sql = "SELECT category_id,category_name 
				FROM   category_mst 
				WHERE  pid = 0 and del_flag=0
				ORDER BY category_id ";
		$result = mysql_query($sql);
		
		while($row=mysql_fetch_array($result)) 
		{
       		$html.='<img src="img/folder1.gif" ><a href="subcategorylist.php?bigCatId='.$row[0].'" utn>'.$row[1].'</a><br>'."\n";
   		}
		$this->html = $html;
		$this->topicPath = "<a href=/top_page.php>トップ</a>>".'ｶﾃｺﾞﾘﾘｽﾄ ';
	}
	
	function getSubCatList($bigCatId)
	{
		$html = "";
		$sql = "SELECT category_id,category_name 
				FROM   category_mst 
				WHERE  category_id=$bigCatId and pid = 0 and del_flag=0";
		$result = mysql_query($sql);
		$row = mysql_fetch_array($result);

		$this->topicPath = "<a href=/top_page.php>トップ</a>>".'<a name="category" href="categorylist.php">'.$row[1].'</a>>ｻﾌﾞｶﾃｺﾞﾘﾘｽﾄ';
		$html.= '<img src="img/folder1.gif" >'.$row[1].'<br>'."\n";
		
		$sql = "SELECT category_id,category_name 
				FROM   category_mst 
				WHERE  pid = $bigCatId and del_flag=0";
		$result = mysql_query($sql);
		while($row=mysql_fetch_array($result)) 
		{
       		$html.='┗<a href="taglist.php?subCatId='.$row[0].'" utn>'.$row[1].'</a><br>'."\n";
   		}
		$this->html = $html;

		
	}
	
	function getTagList($subCatId)
	{
		$html = "";
		$sql = "SELECT cat2.category_id, cat2.category_name, cat1.category_id, cat1.category_name 
				FROM   category_mst cat1 join  category_mst cat2 on cat1.pid=cat2.category_id 
				WHERE  cat1.category_id=$subCatId and cat1.del_flag=0";
		$result = mysql_query($sql);
		$row = mysql_fetch_array($result);
		$this->topicPath = "<a href=/top_page.php>トップ</a>>".'<a name="category" href="categorylist.php">'.$row[1].'</a>>'
		         .'<a name="subcategory" href="subcategorylist.php?bigCatId='.$row[0].'">'.$row[3].'</a>>ﾀｸﾞﾘｽﾄ';
		$html.= '<img src="img/folder1.gif" >'.$row[1].'<br>'."\n";
		
		$sql = "SELECT tag_id,tag_name 
				FROM   tag_mst 
				WHERE  category_id=$subCatId
				ORDER BY entry_cnt desc
				limit 0,15";
		$result = mysql_query($sql);
		while($row=mysql_fetch_array($result)) 
		{
       		$html.='┗<a href="result_list.php?tagId='.$row[0].'&categoryId='.$subCatId.'" utn>'.$row[1].'</a><br>'."\n";
   		}
		$this->html = $html;
		
	}
	
	
	
}
?>